#import "ZHMWToolView.h"
#import "ZHPhotoBrowserDefine.h"

@interface ZHMWToolView ()

@property (nonatomic, strong) UIButton *shareBtn;
@property (nonatomic, strong) UIButton *saveBtn;

@end

@implementation ZHMWToolView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self configSubViews];
    }
    return self;
}

#pragma mark - button respione
- (void)shareButtonClicked:(id)sender {
    if (self.clickBlock) {
        self.clickBlock(0);
    }
}
- (void)saveButtonClicked:(id)sender {
    if (self.clickBlock) {
        self.clickBlock(1);
    }
}

#pragma mark - Subviews
- (void)configSubViews {
    
    self.backgroundColor = [UIColor blackColor];
    
    _shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _shareBtn.frame = CGRectMake(0, 0, CGRectGetWidth(self.bounds)/2, CGRectGetHeight(self.bounds));
    _shareBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [_shareBtn setImage:MWBrowserImageNamed(@"mw_btn_share") forState:UIControlStateNormal];
    [_shareBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_shareBtn setTitle:NSLocalizedString(@"分享给朋友", nil) forState:UIControlStateNormal];
    _shareBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [_shareBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -5, 0, 5)];
    [_shareBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 5, 0, -5)];

    [_shareBtn addTarget:self action:@selector(shareButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_shareBtn];
    
    _saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _saveBtn.frame = CGRectMake(CGRectGetWidth(self.bounds)/2, 0, CGRectGetWidth(self.bounds)/2, CGRectGetHeight(self.bounds));
    _saveBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [_saveBtn setImage:MWBrowserImageNamed(@"mw_btn_save_image") forState:UIControlStateNormal];
    [_saveBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_saveBtn setTitle:NSLocalizedString(@"保存到本地", nil) forState:UIControlStateNormal];
    _saveBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [_saveBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -5, 0, 5)];
    [_saveBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 5, 0, -5)];

    [_saveBtn addTarget:self action:@selector(saveButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_saveBtn];
    
}
@end
